package cc.zy.base.businesses.service.impl;


import cc.zy.base.businesses.entity.EntranceScore;
import cc.zy.base.businesses.entity.ErrorLog;
import cc.zy.base.businesses.mapper.EntranceScoreMapper;
import cc.zy.base.businesses.service.IEntranceScoreService;
import cc.zy.base.common.entity.FebsConstant;
import cc.zy.base.common.entity.QueryRequest;
import cc.zy.base.common.utils.SortUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation;
import lombok.RequiredArgsConstructor;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.servlet.http.HttpSession;

/**
 * Service实现
 *
 * @author Jiangjinlin
 * @date 2021-01-23 23:11:18
 */
@Service
@Slf4j
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class EntranceScoreServiceImpl extends ServiceImpl<EntranceScoreMapper, EntranceScore> implements IEntranceScoreService {

    private final EntranceScoreMapper entranceScoreMapper;

    /**
     * 获取错误日志信息
     *
     * @return
     */
    @Override
    public IPage<ErrorLog> getErrorLogs(QueryRequest request, HttpSession session) {
        String unique = (String) session.getAttribute("unique");
        Page<ErrorLog> page = new Page<>(request.getPageNum(), request.getPageSize());
        page.setSearchCount(false);
        page.setTotal(this.baseMapper.getErrorLogsDetail(unique));
        SortUtil.handlePageSort(request, page, "CREATE_TIME", FebsConstant.ORDER_DESC, false);
        return this.baseMapper.getErrorLogs(page, unique);
    }

   }
